Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Mongoose import from file "buffering timed out"

I'm trying to import some .json data to mongo, but when trying to save() a person, it just waits some seconds and then crashes with an error: MongooseError: Operation people.insertOne() buffering timed out after 10000ms It's weird, because when I'm doing POST request it works fine, the person is added correctly. I wrote some console.logs for help, and it prints the person correctly (inside for loop).

My import script file:

const fs = require('fs/promises')
const express = require('express')
const Person = require('../models/people')
const router = express.Router()

const importData = async () => {
    const data = await fs.readFile('./people.json')
    console.log(data)
    const dataParsed = JSON.parse(data)
    for(const person of dataParsed) {
        const personToSave = new Person({
            firstName: person.firstName,
            lastName: person.lastName
        })
        console.log(personToSave)
        await personToSave.save()
    }
}
importData()

module.exports=router

My connect:

const express = require('express');
const app = express();
const mongoose = require('mongoose');
const people = require('./routers/people');
const pets = require('./routers/pets');
const aggregate = require('./routers/aggregate');
const port = 3000;

app.use(express.json());
app.use('/people', people);
app.use('/pets', pets);
app.use('/aggregate', aggregate);

mongoose.connect('mongodb://localhost:27017/people').then(() => {
  console.log('Connected to mongoDB');
  app.listen(port, () => {
    console.log(`App is listening at port ${port}`);
  });
});
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!